<template>
  <!--data 前不加： 表示字符串，加的话表示对象-->
  <div class="components-container">
    <el-upload
      action="/dev-api/ibest/user/pic/upload"
      list-type="picture-card"
      name="pic"
      :data="user"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove">
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script>

export default {
  name: 'AvatarUploadDemo',
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
      user: {
        token: '00001'
      }
    }
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    }
  }
}
</script>

<style scoped>
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

